#include "message1.h"


MessageLoginRequest::MessageLoginRequest()
{
    setMsgId(m_msgid);
}

MessageLoginRequest::MessageLoginRequest(const LoginData &login):m_Login(login)
{

}

MessageLoginRequest::~MessageLoginRequest()
{

}

uint32_t MessageLoginRequest::getBufferSize() const
{
    uint32_t size = IMessage::SERIALIZED_MSG_HEADER_SIZE;
    size += sizeof(uint32_t) + static_cast<uint32_t>(sizeof(uint8_t) * m_Login.username.size());
    size += sizeof(uint32_t) + static_cast<uint32_t>(sizeof(uint8_t) * m_Login.password.size());
    return size;
}

void MessageLoginRequest::serializeContent(uint8_t **bufPtr) const
{
    StringToBuffer<string, char>(m_Login.username, bufPtr);
    StringToBuffer<string, char>(m_Login.password, bufPtr);
}

void MessageLoginRequest::deserializeContent(uint8_t **bufPtr)
{
    StringFromBuffer<string, char>(bufPtr, m_Login.username);
    StringFromBuffer<string, char>(bufPtr, m_Login.password);
}

